Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add schema support for array items #3218

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oliver-statsig
Copy link

@oliver-statsig oliver-statsig commented Dec 24, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A
When a parameter is specified as an array, the type and items of the parameter are not currently rendered in the schema. E.g.

  @ApiProperty({
    name: '_sortBy',
    nullable: true,
  })
  sortBy: string[];

produces

- name: _sortBy
- in: query
- required: true
- schema:
  - nullable: true

This is not valid OpenAPI 3.0.

What is the new behavior?

type and items are specified in the schema.

- name: _sortBy
- in: query
- required: true
- schema:
  - nullable: true
  - type: array
  - items:
    - type: string

This conforms to the OpenAPI 3.0 spec as described here for how arrays should be serialized in the url: https://swagger.io/docs/specification/v3_0/serialization/#serialization-and-rfc-6570

Does this PR introduce a breaking change?

  • Yes
  • No

This PR would add additional OpenAPI properties an existing spec without any callsite updates. It's possible some existing SDK-generation pipeline based off the specs might be triggered to validate new things, but a spec without items for type: array is not actually valid, which makes me think the chance of breaking SDK generation is fairly slim.

Other information

Add support for `type` and `items` as a schema key, ensuring they work
properly when used in parameter types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants